/**
 * @file 愉快的日常
 * @author Cicime
 * @createtime 2016年4月28日16:15:59
 *
 */

function Cardbox (width,height,canvas,img,kuaimg,inc) {
  this.width = width;
  this.height = height;
  this.canvas = canvas;
  this.img = img;
  this.kuaimg = kuaimg;
  this.inc = inc;
}

Cardbox.prototype = {
  content: function () {
    var _this = this,
        canvas = document.getElementById(this.canvas),
        context = canvas.getContext("2d");
        canvas.width = this.width;
        canvas.height = this.height;
    window.addEventListener('load',function(){
      _this.imgload(context,_this.img);
      _this.imgload(context,_this.kuaimg);
      _this.incload(context,_this.inc);
    });
  },
  imgload: function (context,img) {
    var image = new Image();
        image.src = img;
    image.addEventListener('load',function(){
      context.drawImage(image,0,0,this.width,this.height);
    });
  },
  incload: function (context,img) {
    var image = new Image();
    image.src = img;
    image.addEventListener('load',function(){
      context.drawImage(image,75,70,92,92);
    });
  },
  init: function () {
    this.content();
  }
};

/* @module main */
(function(){
  var card = new Cardbox(460,666,'canvas','img/img1.jpg','img/kuang.png','img/ic1.png');
  card.init();
})();
